capture log close
log using crisis_rep_2020module, replace text
//program:  crisis_rep_2020module.do
//task:    Replication of 2020 CCES module analyses
//project: Politics of Personal Crisis (Ojeda, Michener & Haselswerdt), Political Behavior     
//author: Jake Haselswerdt \ 2024-3-7

//program setup
version 15
clear all
set linesize 80
macro drop _all
set scheme s1mono
graph set window fontface "GillSans"
set more off

use CCES20_crisis_vv.dta, clear
svyset [pw=teamweight]
global controls "voted2016_valid female black hisp other age educ income married churchattend child18_01"

// Figure 1: Histogram/Frequency Distribution
graph twoway (hist total_crises, discrete percent fcolor(gs10) lcolor(white)), ///
	title("CES 2020 Module") ///
	xtitle("Count of Negative Life Events") ///
	xlabel(0 2 4 6 8 10 12 14 16 18 20 22 24, labsize(2.5)) ///
	xtick(0(2)24) ///
	ytitle("Percentage of Respondents") ///
	ylabel(0(10)70, labsize(2.5) angle(horizontal)) ///	
	yscale(titlegap(2)) ///
	xscale(titlegap(2)) ///
	graphregion(fcolor(white)) ///
	scheme(s1mono) graphregion(fcolor(white) margin(l 40)) aspect(1) ///
	saving(cces20mod_hist, replace)

	
// Figure 2 / Table 2 / Appendix D: T-test Results

* Non-COVID Crises
foreach var of varlist crisis_govprog crisis_tax crisis_demotehrs crisis_boss crisis_business crisis_bankrupt crisis_repo crisis_pawn crisis_billscred crisis_utility crisis_healthins crisis_medexp crisis_alcdrug crisis_death crisis_romantic crisis_arrested crisis_sued crisis_discrim crisis_homedestroyed crisis_homepoor crisis_homerepair crisis_landlord crisis_transit crisis_car crisis_license crisis_shelter crisis_home crisis_evicted crisis_rentinc crisis_rentbehind crisis_income crisis_jobloss crisis_divorce crisis_victim crisis_er crisis_paycut{
di ""
di "`:variable label `var''"
ttest voted_valid, by(`var')
di ""
}

* COVID Crises
foreach var of varlist crisis_covidself crisis_covidfam crisis_covidfriend crisis_covidcoworker crisis_covidfamdeath crisis_covidfrienddeath crisis_covidcoworkerdeath crisis_covidhrs crisis_covidlayoff{
di ""
di "`:variable label `var''"
ttest voted_valid, by(`var')
di ""
}

* Figure 2
global crisis_list "crisis_income crisis_jobloss crisis_divorce crisis_victim crisis_er crisis_paycut crisis_covidself crisis_covidfam crisis_covidfriend crisis_covidcoworker crisis_covidfamdeath crisis_covidfrienddeath crisis_covidcoworkerdeath crisis_covidhrs crisis_covidlayoff crisis_govprog crisis_tax crisis_demotehrs crisis_boss crisis_business crisis_bankrupt crisis_repo crisis_pawn crisis_billscred crisis_utility crisis_healthins crisis_medexp crisis_alcdrug crisis_death crisis_romantic crisis_arrested crisis_sued crisis_discrim crisis_homedestroyed crisis_homepoor crisis_homerepair crisis_landlord crisis_transit crisis_car crisis_license crisis_shelter crisis_home crisis_evicted crisis_rentinc crisis_rentbehind"

foreach c in $crisis_list{
ttest voted_valid, by(`c') reverse
matrix mat_`c' = J(1,3,.)
mat mat_`c'[1,1] = r(mu_1)
mat mat_`c'[1,2] = r(mu_2)
mat mat_`c'[1,3] = r(se)
matrix rownames mat_`c' = `c'
}

mat mat_crisis = mat_crisis_income \ mat_crisis_jobloss \ mat_crisis_divorce \ mat_crisis_victim \ mat_crisis_er \ mat_crisis_paycut \ mat_crisis_covidself \ mat_crisis_covidfam \ mat_crisis_covidfriend \ mat_crisis_covidcoworker \ mat_crisis_covidfamdeath \ mat_crisis_covidfrienddeath \ mat_crisis_covidcoworkerdeath \ mat_crisis_covidhrs \ mat_crisis_covidlayoff \ mat_crisis_govprog \ mat_crisis_tax \ mat_crisis_demotehrs \ mat_crisis_boss \ mat_crisis_business \ mat_crisis_bankrupt \ mat_crisis_repo \ mat_crisis_pawn \ mat_crisis_billscred \ mat_crisis_utility \ mat_crisis_healthins \ mat_crisis_medexp \ mat_crisis_alcdrug \ mat_crisis_death \ mat_crisis_romantic \ mat_crisis_arrested \ mat_crisis_sued \ mat_crisis_discrim \ mat_crisis_homedestroyed \ mat_crisis_homepoor \ mat_crisis_homerepair \ mat_crisis_landlord \ mat_crisis_transit \ mat_crisis_car \ mat_crisis_license \ mat_crisis_shelter \ mat_crisis_home \ mat_crisis_evicted \ mat_crisis_rentinc \ mat_crisis_rentbehind

svmat2 mat_crisis, names(col) rnames(crisis_title)

rename c1 ttest_mean0
rename c2 ttest_mean1
rename c3 ttest_se

gen ttest_diff = ttest_mean0 - ttest_mean1
gen ttest_ll = ttest_diff - (1.96*ttest_se)
gen ttest_ul = ttest_diff + (1.96*ttest_se)

gen covid_est = 0
replace covid_est = 1 if (_n > 6 & _n < 16)
replace covid_est = . if _n > 45

gen sig_est = 0
replace sig_est = 1 if ttest_ll > 0 | ttest_ul < 0
replace sig_est = . if _n > 45

sort covid_est ttest_diff

gen n_var = _n
replace n_var = n_var + 1 if _n > 36
replace n_var = . if _n > 46

graph twoway (rspike ttest_ll ttest_ul n_var, horizontal lcolor(black)) ///
			(scatter n_var ttest_diff if sig_est == 0, mcolor(white) mlcolor(black)) ///
			(scatter n_var ttest_diff if sig_est == 1, mcolor(black)), ///
			legend(off) ///
			ylabel(1 "Had driver's license suspended" ///
			2 "Had possessions repossessed" ///
			3 "Evicted" ///
			4 "Lost home" ///
			5 "Arrested or accused of a crime" ///
			6 "Divorced" ///
			7 "Needed, but not had, car for 1 month or more" ///
			8 "Lost eligibility for government program"  ///
			9 "Had problem with alcohol or drugs" ///
			10 "Temporarily lived with others or in a shelter" ///
			11 "Pawned valuables to make ends meet" ///
			12 "Had trouble with boss" ///
			13 "Had serious trouble with romantic partner" ///
			14 "Lived in a house in poor condition" ///
			15 "Been unable to pay utilities" ///
			16 "Lost job" ///
			17 "Lost health insurance" ///
			18 "Fallen behind in paying rent" ///
			19 "Went bankrupt" ///
			20 "Needed but unable to use public transportation" ///
			21 "Pay cut at work" ///
			22 "Had serious troubles with a landlord" ///
			23 "Death of family member or close friend (non-COVID)" /// 
			24 "Been pressured to pay bills or creditors" ///
			25 "Lost eligibility for tax break"  ///
			26 "Had a substantial increase in rent" ///
			27 "Victim of a crime"  ///
			28 "Decreased income" ///
			29 "Been discriminated against" ///
			30 "Owned business that lost money or closed" ///
			31 "Visited an emergency room" ///
			32 "Had trouble affording medical expenses" ///
			33 "Demoted or hours cut (non COVID related)" ///
			34 "Had a home destroyed" ///
			35 "Sued in a civil case" ///
			36 "Had to unexpectedly pay for major home repairs" ///
			38 "Family member died from COVID-19" ///
			39 "Diagnosed with COVID-19" ///
			40  "Work hours reduced during pandemic" ///
			41 "Family member diagnosed with COVID-19" ///
			42 "Coworker diagnosed with COVID-19" ///
			43 "Laid off during pandemic (no to job loss question)" ///
			44 "Friend diagnosed with COVID-19" ///
			45 "Friend died from COVID-19" ///
			46 "Coworker died from COVID-19",  ///
			labsize(2)) ///
			ytitle(" ") ///
			xtitle("Difference in Mean Turnout") ///
			xlabel(-1 -.75 -.5 -.25 0 .25 .5, nogrid labsize(2)) ///
			xline(0, lpattern(dash) lcolor(gs12)) ///
			note("{it:Note}: Estimates represent the difference in mean between respondents who reported the personal crisis and respondents who did not report the personal crisis in the" "CES 2020 Module. The 95% confidence intervals are based on a two-tail t-test of the difference in means.", size(vsmall) span)
	
// Table 3: Cross-tabulation of crisis terciles with voting 
tab lomedhi_covid, sum(covid_crises)
svy: tab voted_valid lomedhi_covid, col 
tab lomedhi_other, sum(other_crises)
svy: tab voted_valid lomedhi_other, col 

// Table 4 & Appendix E: Logistic regressions of voting on personal crisis
svy: logit voted_valid other_crises covid_crises $controls

// Table 5: Models of other participation

*Total count of non-voting participation acts
svy: reg total_part total_crises $controls

*Individual non-voting participation acts
foreach act in meeting sign work protest contact donate{
di " "
di "`:variable label part_`act''"
svy: logit part_`act' total_crises $controls
}

//Appendix C: Descriptives
foreach c in crisis_income crisis_jobloss crisis_divorce crisis_victim crisis_er crisis_paycut crisis_covidself crisis_covidfam crisis_covidfriend crisis_covidcoworker crisis_covidfamdeath crisis_covidfrienddeath crisis_covidcoworkerdeath crisis_covidhrs crisis_covidlayoff crisis_govprog crisis_tax crisis_demotehrs crisis_boss crisis_business crisis_bankrupt crisis_repo crisis_pawn crisis_billscred crisis_utility crisis_healthins crisis_medexp crisis_alcdrug crisis_death crisis_romantic crisis_arrested crisis_sued crisis_discrim crisis_homedestroyed crisis_homepoor crisis_homerepair crisis_landlord crisis_transit crisis_car crisis_license crisis_shelter crisis_home crisis_evicted crisis_rentinc crisis_rentbehind{
di "`: var label `c''"
svy: proportion `c'
}
svy: proportion total_crises

sum voted_valid total_crises covid_crises other_crises $controls [aw=teamweight]

// Appendix F: Demographics and Crises
tab female [aw=teamweight], sum(other_crises)
tab female [aw=teamweight], sum(covid_crises)

gen age_cat = .
replace age_cat = 1 if age < 36
replace age_cat = 2 if age > 35
replace age_cat = 3 if age > 55
tab age_cat [aw=teamweight], sum(other_crises)
tab age_cat [aw=teamweight], sum(covid_crises)
drop age_cat

gen race_new = race
recode race_new 5=4 6=4 7=4 8=4
tab race_new [aw=teamweight], sum(other_crises)
tab race_new [aw=teamweight], sum(covid_crises)
drop race_new

gen educ_degree = educ
recode educ_degree 4=4 5=4 6=4
tab educ_degree [aw=teamweight], sum(other_crises)
tab educ_degree [aw=teamweight], sum(covid_crises)
drop educ_degree

xtile income_quintile = income, nq(5)
tab income_quintile [aw=teamweight], sum(other_crises)
tab income_quintile [aw=teamweight], sum(covid_crises)
drop income_quintile

//Appendix G: Heterogeneous effects

*Dichotomous variables
foreach v in voted2016_valid female white black hisp child18_01{
di "`: var label `v''"
svy: logit voted_valid c.covid_crises##i.`v' c.other_crises##i.`v' $controls
}

*Continuous/ordinal
foreach v in age income educ {
di "`: var label `v''"
svy: logit voted_valid c.covid_crises##c.`v' c.other_crises##c.`v' $controls
}

//Appendix H: possibly chronic vs. short-term non-COVID vs. COVID crises
svy: logit voted_valid chronic_crises shortterm_crises covid_crises $controls

log close
exit
